<?php
namespace App\Http\Controllers\admin;

use DB;
use App\Http\Controllers\common\PublicController;
use Illuminate\Http\Request;

class LayoutController extends PublicController
{
    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index(Request $request)
    {
        $agent_id = $request -> cookie('logon')['agent_id'];
        //查询image库
        $res = DB::table('image') -> select('name','agent_id') -> where(['agent_id'=>$agent_id,'status'=>1]) -> first();
        //获取账号信息
        $account = $request -> cookie('logon')['account'];
        return view('admin.layout.adminlayout',['data'=>$res,'account'=>$account]);
    }

    //请求侧边栏
    public function gadget(){
        $info = $this -> authInfo(true);
        echo json_encode($info);
    }

    //鼠标移入更换头像接口
    public function change(Request $request){
        $agent_id = $request -> cookie('logon')['agent_id'];
        //查询image库
        $res = DB::table('image') -> select('name','agent_id') -> where(['agent_id'=>$agent_id,'status'=>1]) -> first();
        return json_encode($res);
    }
}
